// webpack.config.js
var webpack = require('webpack');
//var ExtractTextPlugin = require("extract-text-webpack-plugin");//webpack的插件
var path = require('path');

module.exports = {
	//页面入口文件配置
	entry: [
		//'webpack-dev-server/client?http://127.0.0.1:3000/',//资源服务器地址
		//'webpack/hot/dev-server',
		'./index.js'
    ],
	//入口文件输出配置
	output: {
		path: path.join(__dirname, 'out'),  //打包输出的路径
		filename: 'bundle.js',			  //打包后的名字
		publicPath: "./out/"				//html等静态资源引用路径,这里写的本地路径
    },
    module: {
		//加载器配置 "-loader"其实是可以省略不写的，多个loader之间用“!”连接起来
		loaders: [
			//.css 文件使用 style-loader 和 css-loader 来处理
			{ test: /\.css$/, loader: 'style-loader!css-loader' },
			//{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") },
			//.js 文件使用 jsx-loader 来编译处理
			{ test: /\.js$/, loader: 'jsx-loader?harmony' },
			//.scss 文件使用 style-loader、css-loader 和 sass-loader 来编译处理
			{ test: /\.scss$/, loader: 'style!css!sass?sourceMap'},
			//图片文件使用 url-loader 来处理，小于40kb的直接转为base64,大于40的会输入进fonts文件夹
			{ test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=40000&name=fonts/[name].[ext]'}
			//注释 将jQuery配置到全局，bootstrap.min.js里就能引用到。
			//{test: path.resolve(__dirname, 'node_modules/jquery/dist/jquery.min.js'), loader: 'expose?jQuery'},	
		]
	},
	plugins: [
	    new webpack.ProvidePlugin({
			$: "jquery",
		    jQuery: "jquery",
		    "window.jQuery": "jquery",
		})
		//,new ExtractTextPlugin("bundle.css")
	  ],
	//其它解决方案配置
    resolve: {
        //查找module的话从这里开始查找
        root: [path.join(__dirname, "js")], //绝对路径
        //自动扩展文件后缀名，意味着我们require模块可以省略不写后缀名
        extensions: ['', '.js', '.json', '.scss'],
        //模块别名定义，方便后续直接引用别名，无须多写长长的地址
        alias: {
        	//页面
        	'homeController' : 'controller/layout/homeController',
            'headerController' : 'controller/layout/headerController',
            'footerController' : 'controller/layout/footerController',
			'404Controller' : 'controller/layout/404Controller',
			'loginController' : 'controller/layout/loginController',
            //开发指南模块
            'devhelpController' : 'controller/devhelp/devhelpController',
            'i18ndemoController' : 'controller/devhelp/i18ndemoController',
            'commonbtnController' : 'controller/devhelp/commonbtnController',
            'echartsController' : 'controller/devhelp/echartsController',
            'alertmodelController' : 'controller/devhelp/alertmodelController',
			'codemirrorController' : 'controller/devhelp/codemirrorController',
			'd3Controller' : 'controller/devhelp/d3Controller',
			'fontawesomeController' : 'controller/devhelp/fontawesomeController',
			'ngtableController' : 'controller/devhelp/ngtableController',	
			//demo
			'SubscriberController' : 'controller/devhelp/SubscriberController',
            'SubscriberDetailController' : 'controller/devhelp/SubscriberDetailController',
			//graphone 图形控制
			'graphController' : 'controller/graph/graphController',
			//备份恢复
			'recoveryController' : 'controller/recovery/recoveryController',
			'backupController' : 'controller/recovery/backupController',
			'restoreController' : 'controller/recovery/restoreController'
        }
    },
	devServer: {
		historyApiFallback: true,
		hot: true,
		inline: true,
		progress: true,
	}
};
